﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace WebApp.Entities
{
    public partial class PowerContext : DbContext
    {
        private readonly string _dbconn;
        public PowerContext(DbContextOptions<PowerContext> options)
            : base(options)
        {
            
        }

        public virtual DbSet<User> Users { get; set; }
        public virtual DbSet<Application> Applications { get; set; }
        public virtual DbSet<Subscribe> Subscribes { get; set; }
        public virtual DbSet<Collector> Collectors { get; set; }
        public virtual DbSet<Meter> Meters { get; set; }
        public virtual DbSet<MeterRecord> MeterRecords { get; set; }
        public virtual DbSet<Operation> Operations { get; set; }
        public virtual DbSet<ExceptionLog> ExceptionLogs { get; set; }


        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //if (!string.IsNullOrEmpty(_dbconn))
            //    optionsBuilder.UseMySql(_dbconn);
            //optionsBuilder.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
            //if (string.IsNullOrEmpty(_dbconn))
            //    optionsBuilder.UseMySql("Data Source=118.25.182.185;port=30508;Database=power;User=root;Password=CCt9s4ZIOg01Y23r173zRC;");
           
            base.OnConfiguring(optionsBuilder);

        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
          
            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
